package com.ylbh.modules.rechargeablecard.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ylbh.common.pojo.rechargeablecard.dto.CardListDTO;
import com.ylbh.common.pojo.rechargeablecard.vo.CardListVO;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.modules.rechargeablecard.entity.RechargeableCard;
import com.ylbh.modules.rechargeablecard.mapper.RechargeableCardMapper;
import com.ylbh.modules.rechargeablecard.service.RechargeableCardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 充值卡
 */
@Service
public class RechargeableCardServiceImpl extends ServiceImpl<RechargeableCardMapper, RechargeableCard> implements RechargeableCardService {

    @Autowired
    private RechargeableCardMapper rechargeableCardMapper;

    /**
     * 充值卡列表
     * @param cardListDTO
     * @return
     */
    @Override
    public PageUtils queryCardList(CardListDTO cardListDTO) {
        Page<Object> page = new Page<>(cardListDTO.getPage(), cardListDTO.getLimit());
        List<CardListVO> cardList = rechargeableCardMapper.selectCardList(cardListDTO, page);
        return new PageUtils(new Page<CardListVO>().setTotal(page.getTotal()).setRecords(cardList));
    }

    /**
     * 充值卡状态修改
     * @param ids
     * @param type
     */
    @Override
    public void modifyRechargeableCardStatusById(List<String> ids, String type) {
        rechargeableCardMapper.updateRechargeableCardStatusById(ids, type);
    }
}
